/**************************************************************************************
*
*	Copyright (C) 2009 - 2012 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	ShaderResource.h
*
*	Description -	Base class containing resource views.
*
*	Comments	-	
*
*	Modification History:
*			Name			   Date					Description
*			MrCodeSushi	-	4/30/2012	-	Creation of this file
**************************************************************************************/
#ifndef _PSX_GRAPHICS_RESOURC_H_
#define _PSX_GRAPHICS_RESOURC_H_

#include "PulseSTD.h"
#include "GraphicsTypes.h"
#include "GraphicsInfrastructure.h"

namespace Pulse
{
	PSX_EnumBegin( EShaderResource )
		UNKNOWN = -1,
		TEXTURE2D,
		TEXTURE3D,
		BUFFER,
		STRUCTURED_BUFFER,
		UNORDERED_ACCESS,
	PSX_EnumEnd()

	// NOTE: May have to be renamed to better reflect the resources 
	//	that has resource view.
	class ShaderResource
	{
	public:

		ShaderResource( void );

		virtual ~ShaderResource( void );

		const void * GetNakedShaderResource( void ) const { return (void*)m_pSRV; }

		const void * GetNakedRenderTargetResource( void ) const { return (void*)m_pRTV; }
	
		const void * GetNakedDepthStencilResource( void ) const { return (void*)m_pDSV; }
		
		const void * GetNakedUnorderedAccessResource( void ) const { return (void*)m_pUAV; }

		const EShaderResource::Type GetShaderResourceType( void ) const { return m_shaderResourceType; }
	
		void SetShaderResourceType( EShaderResource::Type type ) { m_shaderResourceType = type; }

	protected:

		void CreateResourceViews( ID3D11Resource *pResource, UINT bindFlags );

		void CreateResourceViews( ID3D11Resource *pResource, UINT bindFlags, 
			DepthStencilViewDesc *pDSV, ShaderResourceViewDesc *pSRV, UnorderedAccessViewDesc *pUAV );

		void ReleaseResourceViews( void );

	protected:

		friend Renderer;

		EShaderResource::Type m_shaderResourceType;

		ID3D11ShaderResourceView	*m_pSRV;
		ID3D11RenderTargetView		*m_pRTV;
		ID3D11DepthStencilView		*m_pDSV;
		ID3D11UnorderedAccessView	*m_pUAV;

	};

}

#endif /* _PSX_GRAPHICS_RESOURC_H_ */